package me.alex.lifecycledemo;

import androidx.lifecycle.LifecycleService;

/**
 * ================================================
 * Description:
 * <p>
 * Created by Alex on 2021/12/31
 * <p>
 * 页面内容介绍: 在service中使用Lifecycle与Activity和Fragment中一样 但是需要继承LifecycleService,然后在service中使用实现了LifecycleObserver的持有类
 *          原本以为可以让Service也可以绑定某组件的生命周期,实际是让Service拥有View组件相同的功能,Service的声明周期仍要手动处理
 * <p>
 * ================================================
 */
public class LifeService extends LifecycleService {

    @Override
    public void onCreate() {
        super.onCreate();
        getLifecycle().addObserver(new ServiceLifeObserver());
    }
}
